import Vue from "vue";
import VueRouter from "vue-router";


import login from '@/views/login';
import reg from '@/views/reg';
import hello from '@/views/hello';
import home from '@/views/home';
import appGoods from '@/views/appGoods';
import appUsers from '@/views/appUsers';
import appOrders from '@/views/appOrders';
import appShops from '@/views/appShops';


Vue.use(VueRouter);

const routes = [
  {
    path:'/',
    redirect:'/hello'
  },
  {
    path: '/hello',
    name: 'hello',
    component: hello
  },
  {
    path: '/login',
    name: 'login',
    component: login
  },
  {
    path: '/reg',
    name: 'reg',
    component: reg
  },
  {
    path: '/home',
    name: 'home',
    component: home,
    children: [//设置子路由
      {
        path: 'goods',
        name: 'goods',
        component: appGoods
      }, {
        path: 'users',
        name: 'users',
        component: appUsers
      }, {
        path: 'orders',
        name: 'orders',
        component: appOrders
      }, {
        path: 'shops',
        name: 'shops',
        component: appShops
      }
    ]
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
